package hk_14;

import java.util.Random;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        rand rd = new rand();
        int count = 0;

        for (int i = 0; i < 3; i++) {
            System.out.println("请输入你要猜拳的数。");
            System.out.println("0--->石头  1--->剪刀  2--->布");
            int num = sc.nextInt();
            int guess = rd.Product_Random_num();

            if (num == guess) {
               System.out.println("你和电脑平局");
                System.out.println(guess);
           } else if (num == 0 && guess == 1 ) {
                System.out.println("你赢了");
                System.out.println(guess);
                count++;
            } else if (num == 1 && guess == 2) {
                System.out.println("你赢了");
                System.out.println(guess);
                count++;
            } else if (num == 2 && guess == 0) {
                System.out.println("你赢了");
                System.out.println(guess);
                count++;
            }
            else
            {
                System.out.println("你输了");
                System.out.println(guess);
            }
        }

        System.out.println("你赢了电脑"+count+"次");
    }
}

class rand {
    public int Product_Random_num(){
        Random rd = new Random();
        int random = rd.nextInt(3);
        return random;
    }

    public void setResult(){
        switch (this.Product_Random_num()) {
            case 0 -> System.out.println("电脑出石头");
            case 1 -> System.out.println("电脑出剪刀");
            case 2 -> System.out.println("电脑出布");
            default -> System.out.println("电脑出了什么");
        }
    }
}
